package com.kelvin.paopao.module.market.wallet.wallet;

import com.kelvin.paopao.api.RetrofitService;
import com.kelvin.paopao.api.responseBean.CommonListResponse;
import com.kelvin.paopao.api.responseBean.UserMoneyBean;
import com.kelvin.paopao.module.base.IBasePresenter;

import io.reactivex.annotations.NonNull;
import io.reactivex.functions.Consumer;

/**
 * Created by Administrator on 2017/5/10.
 */

public class WalletPresenter implements IBasePresenter {

    private WalletActivity mView;

    public WalletPresenter(WalletActivity view) {
        this.mView = view;
    }

    @Override
    public void getData(boolean isRefresh) {
        RetrofitService.getMoney().subscribe(new Consumer<CommonListResponse
                <UserMoneyBean>>() {
            @Override
            public void accept(@NonNull CommonListResponse<UserMoneyBean>
                                       commonListResponse) throws Exception {
                UserMoneyBean bean = commonListResponse.getResult().get(0);
                mView.setVip(bean.getIsvip() == 1 ? true : false, bean.getUser_vipdate());
                mView.setMoney(String.valueOf(bean.getUser_blance()));
            }
        });
    }

    @Override
    public void getMoreData() {

    }
}
